$().ready(function() {
	validateRule();
});

$("#startDate").datetimepicker({
	format: "yyyy-mm-dd",
    autoclose: true,
    //forceParse: true,
    clearBtn: true,
    todayBtn: true,
    todayHighlight: true,
    showMeridian: true,
    pickerPosition: "bottom-left",
    language: 'zh-CN',//中文，需要引用zh-CN.js包
    startView: 2,//月视图
    minView: 2,//日期时间选择器所能够提供的最精确的时间选择视图
    //startDate:$("#startDate").val()
}).on('changeDate',function(e){  
    var startTime = e.date;  
    $('#endDate').datetimepicker('setStartDate',startTime);  
});  

$("#endDate").datetimepicker({
	format: "yyyy-mm-dd",
    autoclose: true,
    //forceParse: true,
    clearBtn: true,
    todayBtn: true,
    todayHighlight: true,
    showMeridian: true,
    pickerPosition: "bottom-left",
    language: 'zh-CN',//中文，需要引用zh-CN.js包
    startView: 2,//月视图
    minView: 2//日期时间选择器所能够提供的最精确的时间选择视图
}).on('changeDate',function(e){  
    var endTime = e.date;  
    $('#startDate').datetimepicker('setEndDate',endTime);  
});

$("#signUpEndDate").datetimepicker({
	format: "yyyy-mm-dd",
    autoclose: true,
    //forceParse: true,
    clearBtn: true,
    todayBtn: true,
    todayHighlight: true,
    showMeridian: true,
    pickerPosition: "bottom-left",
    language: 'zh-CN',//中文，需要引用zh-CN.js包
    startView: 2,//月视图
    minView: 2//日期时间选择器所能够提供的最精确的时间选择视图
});

$.validator.setDefaults({
	submitHandler : function() {
		update();
	}
});
function update() {
	$.ajax({
		cache : true,
		type : "POST",
		url : "/act/actDetails/update",
		data : $('#signupForm').serialize(),// 你的formid
		async : false,
		error : function(request) {
			parent.layer.alert("Connection error");
		},
		success : function(data) {
			if (data.code == 0) {
				parent.layer.msg("操作成功");
				parent.reLoad();
				var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
				parent.layer.close(index);

			} else {
				parent.layer.alert(data.msg)
			}

		}
	});

}
function validateRule() {
	var icon = "<i class='fa fa-times-circle'></i> ";
	$("#signupForm").validate({
		rules : {
			name : {
				required : true
			}
		},
		messages : {
			name : {
				required : icon + "请输入名字"
			}
		}
	})
}

var openType = function(){
	layer.open({
		type:2,
		title:"活动类别",
		area : [ '300px', '450px' ],
		content:"/act/actType/treeView"
	})
}

function loadDept( typeId,typeName){
	$("#typeId").val(typeId);
	$("#typeName").val(typeName);
}

function preview(id) {
	window.open("/blog/open/post/"+id);   
	//window.location.href="/blog/open/post/"+id;
}